package org.starlight.user.serivce.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.starlight.delete.DeleteRecordHelper;
import org.starlight.delete.enums.TableEnum;
import org.starlight.user.entity.Roles;
import org.starlight.user.repository.RolesRepository;
import org.starlight.user.serivce.RolesService;

/**
 * @author huangyong
 * @data 2025/2/28
 */

@Slf4j
@Service
@RequiredArgsConstructor
public class RolesServiceImpl implements RolesService {
    private final RolesRepository rolesRepository;

    @Override
    public void saveRole(Roles roles) {
        rolesRepository.save(roles);
    }

    @Override
    public void delRole(Integer id) {
        DeleteRecordHelper.saveDeleteRecord(TableEnum.roles, rolesRepository.findById(id).orElse(null));
        rolesRepository.deleteById(id);
    }
}
